﻿using Appliaction.Dto.DB;
using Appliaction.IAppServices.DB;
using AutoMapper;
using Domain.Entitys.DB;
using Domain.IRepositorys.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Appliaction.AppServices.DB
{
    /// <summary>
    /// Appliaction下面的仓库库区(实现Domain下面的接口)
    /// </summary>
    public class Db_warehouse_zoneServices : IDb_warehouse_zoneServices
    {
        private readonly DB_warehouse_zone db_Warehouse_Zone;

        private readonly IMapper mapper;

        public Db_warehouse_zoneServices(DB_warehouse_zone db_Warehouse_Zone, IMapper mapper)
        {
            this.db_Warehouse_Zone = db_Warehouse_Zone;
            this.mapper = mapper;
        }
        /// <summary>
        /// 库区查询总数
        /// </summary>
        /// <param name="warehouse_name"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int Select_count_warehouse_zone(string warehouse_code, string zone_name)
        {
            return db_Warehouse_Zone.Select_count_warehouse_zone(warehouse_code, zone_name);
        }
        /// <summary>
        /// 库区分页查询
        /// </summary>
        /// <param name="warehouse_name"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Warehouse_zone> Select_fy_warehouse_zone(string warehouse_code, string zone_name, int currentPage, int pageSize)
        {
            return db_Warehouse_Zone.Select_fy_warehouse_zone(warehouse_code, zone_name, currentPage, pageSize);
        }
        /// <summary>
        /// 仓库库区修改冻结状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="zone_freeze"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> warehouse__zone_Frozenstate(int id, char zone_freeze)
        {
            return db_Warehouse_Zone.warehouse__zone_Frozenstate(id,zone_freeze);
        }

        /// <summary>
        /// 仓库库区编码唯一性判断
        /// </summary>
        /// <param name="zone_code"></param>
        /// <param name="warehouse_code"></param>
        /// <returns></returns>
      public Task<int> Warehousezone_code_judgment(string zone_code, string warehouse_code) { 
        
        return db_Warehouse_Zone.Warehousezone_code_judgment(zone_code, warehouse_code);
        }

        /// <summary>
        /// 仓库库区名称唯一性判断
        /// </summary>
        /// <param name="zone_name"></param>
        /// <param name="warehouse_code"></param>
      public  Task<int> Warehousezone_name_judgment(string zone_name, string warehouse_code) { 
        return db_Warehouse_Zone.Warehousezone_name_judgment(zone_name, warehouse_code);
      }
        /// <summary>
        /// 仓库库区添加
        /// </summary>
        /// <param name="db_WarhousezoneAddDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> Warehousezone_Add(Db_warhousezoneAddDto db_WarhousezoneAddDto)
        {
          Warehouse_zone warehous_zone=mapper.Map<Warehouse_zone>(db_WarhousezoneAddDto);
            return db_Warehouse_Zone.Warehousezone_Add(warehous_zone);
        }
 
        /// <summary>
        /// 仓库库区点击不允许产品混放
        /// </summary>
        /// <param name="id"></param>
        /// <param name="zone_mixing"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Warehousezone_ProductMixNO(Db_Warehouse_zone_UpdateDto db_Warehouse_zone_UpdateDto)
        {
            var warhouse_zone = mapper.Map<Warehouse_zone>(db_Warehouse_zone_UpdateDto);
            return await db_Warehouse_Zone.Warehousezone_ProductMixNO(warhouse_zone);
        }
        /// <summary>
        /// 仓库库区点击允许批次混放   
        /// </summary>
        /// <param name="id"></param>
        /// <param name="zone_batch_mixing"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Warehousezone_BatchMix(Db_Warehouse_zone_UpdateDto db_Warehouse_zone_UpdateDto)
        {
            var warhouse_zone = mapper.Map<Warehouse_zone>(db_Warehouse_zone_UpdateDto);
            return await db_Warehouse_Zone.Warehousezone_BatchMix(warhouse_zone);
        }
        /// <summary>
        /// 仓库库区点击不允许混放
        /// </summary>
        /// <param name="id"></param>
        /// <param name="zone_batch_mixing"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Warehousezone_BatchMixNO(Db_Warehouse_zone_UpdateDto db_Warehouse_zone_UpdateDto)
        {
            var warhouse_zone = mapper.Map<Warehouse_zone>(db_Warehouse_zone_UpdateDto);
            return await db_Warehouse_Zone.Warehousezone_BatchMixNO(warhouse_zone);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="db_Warehouse_zone_UpdateDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Warehousezone_ProductMix(Db_Warehouse_zone_UpdateDto db_Warehouse_zone_UpdateDto)
        {
            var warehous_zone = mapper.Map<Warehouse_zone>(db_Warehouse_zone_UpdateDto);
             return await db_Warehouse_Zone.Warehousezone_ProductMix(warehous_zone);
        }


        /// <summary>
        /// 判断仓库库区添加的容量是否超过仓库容量
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <param name="zone_capacity"></param>
        /// <returns></returns>
         public Task<int> Warehousezone_Capacity_judgment(string warehouse_code, int zone_capacity) { 
        
            return db_Warehouse_Zone.Warehousezone_Capacity_judgment(warehouse_code, zone_capacity);
        }
        /// <summary>
        /// 修改仓库库区信息
        /// </summary>
        /// <param name="db_Warehouse_ZoneUpdatexgDto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async  Task<int> Warehousezone_Update(Db_warehouse_ZoneUpdatexgDto db_Warehouse_ZoneUpdatexgDto)
        {
            var warhouse_zone_update = mapper.Map<Warehouse_zone>(db_Warehouse_ZoneUpdatexgDto);
            return await db_Warehouse_Zone.Warehousezone_Update(warhouse_zone_update);
        }
        /// <summary>
        /// 删除库区
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <param name="zone_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> warehouse_zone_tombstone(string warehouse_code, string zone_code)
        {
           return db_Warehouse_Zone.warehouse_zone_tombstone(warehouse_code, zone_code);
        }
        /// <summary>
        /// 查询库区
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public List<Warehouse_zone> warehouse_zone_Async(string warehouse_code)
        {
           return db_Warehouse_Zone.warehouse_zone_Async(warehouse_code);
        }

        /// <summary>
        /// 结构编码查询仓库信息
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <returns></returns>
        public List<Warehouse_zone> Warehouse_zone_By_Select_Async_code(string warehouse_code, string zone_code) { 
        
        return db_Warehouse_Zone.Warehouse_zone_By_Select_Async_code(warehouse_code, zone_code);
        }

        /// <summary>
        /// 判断仓库库区修改的容量是否超过仓库容量
        /// </summary>
        /// <param name="warehouse_code"></param>
        /// <param name="zone_capacity"></param>
        /// <returns></returns>
        public Task<int> Warehousezone_Capacity_judgment_update(string warehouse_code, string zone_code, int new_zone_capacity) { 
        
        
        return db_Warehouse_Zone.Warehousezone_Capacity_judgment_update(warehouse_code, zone_code, new_zone_capacity);
        }


        /// <summary>
        /// 修改名称判断
        /// </summary>
        /// <param name="zone_name"></param>
        /// <param name="warehouse_code"></param>
        /// <param name="zone_code"></param>
        /// <returns></returns>
        public Task<int> Warehousezone_name_UpdateJudgment(string zone_name, string warehouse_code, string zone_code) { 
        
        return db_Warehouse_Zone.Warehousezone_name_UpdateJudgment(zone_name, warehouse_code, zone_code);
        }

    }
}
